
import originJSONP from 'jsonp'
function params(data){
    let url = ''
  for (var k in data) {
    let value = data[k] !== undefined ? data[k] : ''
    url += '&' + k + '=' + encodeURIComponent(value)
  }
  return url ? url.substring(1) : ''
}
export function jSonp(url,data,option){
    url+=(url.indexOf('?')<0 ? '?':'&')+params(data)
    return Promise((resolve,reject)=>{
        originJSONP(url,option,function(err,data){
            if(!err){
                console.log('jsonp',data);
                resolve(data)
            }else{
                reject(err)
            }

        })
    })
}